#ifndef __BYTE_QUEUE_H
#define __BYTE_QUEUE_H

#include ".\app_cfg.h"

typedef struct __byte_queue_t byte_queue_t;
struct __byte_queue_t {
    uint8_t chHead;
    uint8_t chTail;
    uint8_t chSize;
    uint8_t chLength;
    uint8_t *ptBuf;
    
    uint8_t chPeekedCount;
    uint8_t chPeekHead;
};

#define INIT_BYTE_QUEUE(__QUEUE, __BUFFER, __SIZE) byte_queue_init(__QUEUE, __BUFFER, __SIZE)

#define PEEK_BYTE_QUEUE(__QUEUE, __ADDR)    byte_queue_peek(__QUEUE, __ADDR)

#define RESET_PEEK_BYTE(__QUEUE)        byte_queue_reset_peek(__QUEUE)

#define GET_ALL_PEEKED_BYTE(__QUEUE)    byte_queue_get_all_peeked(__QUEUE)

#define ENQUEUE_BYTE(__QUEUE, __OBJ)    byte_queue_in(__QUEUE, __OBJ)

#define DEQUEUE_BYTE(__QUEUE, __ADDR)   byte_queue_out(__QUEUE, __ADDR)

#define IS_BYTE_QUEUE_INIT(__QUEUE)     byte_queue_is_empty(__QUEUE)

#define BYE_QUEUE_SIZE(__QUEUE)         byte_queue_size(__QUEUE)

extern bool byte_queue_init(byte_queue_t* ptQueue, uint8_t* pchBuffer, uint8_t chSize);
extern bool byte_queue_in(byte_queue_t* ptQueue, uint8_t* pchVal);
extern bool byte_queue_out(byte_queue_t* ptQueue, uint8_t* pchVal);
extern bool byte_queue_is_empty(byte_queue_t* ptQueue);
extern bool byte_queue_reset_peek(byte_queue_t* ptQueue);
extern bool byte_queue_get_all_peeked(byte_queue_t* ptQueue);
extern uint8_t byte_queue_size(byte_queue_t* ptQueue);
extern bool byte_queue_peek(byte_queue_t* ptQueue, uint8_t* pchVal);

#endif
